<?php
/**
 * 请求插件接口
 */
namespace App;
defined('IN_IA') or exit('Access Denied');
class PluginApi{

    private $_api = '';

    public function __construct($_name)
    {
        $this->_api = murl('entry//api',array('m'=>'kuyuan_fm_plugin_'.$_name),true,true);
    }

    public function request($_action,Array $_data = array())
    {
        $_action = explode("/",$_action);
        $_data["pages"] = $_action[0];
        $_data["doing"] = $_action[1];
        $_data["sign"] = $this->getSign($_data);
        $_result = ihttp_post($this->_api,$_data);
        return $_result["content"];
    }

    /**
     * 获取sign
     * @param array $_data 数据
     * @return string sign
     */
    private function getSign($_data)
    {
        $_key_arr = array_keys($_data);
        sort($_key_arr,SORT_STRING);
        $_key_str = '';
        foreach($_key_arr as $_v){
            $_key_str .= $_v;
        }
        $_key_str .= "shanxikuyuanwangluokeji";
        return strtoupper(md5($_key_str));
    }

}